package com.liy.supercloud.ssoserver.aop;

import com.liy.supercloud.ssoserver.util.URLExcluder;
import java.util.Iterator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebMVCConfig implements WebMvcConfigurer {
    private static Logger log = LoggerFactory.getLogger(WebMVCConfig.class);

    @Autowired
    private ServiceAuthorizationInterceptor serviceAuthorizationInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        log.info("Added Authentication Interceptor Successfully.");
        InterceptorRegistration interceptorRegistration = registry.addInterceptor(this.serviceAuthorizationInterceptor);
        interceptorRegistration.addPathPatterns(new String[]{"/**"});
        Iterator var3 = URLExcluder.urlList.iterator();

        while(var3.hasNext()) {
            String url = (String)var3.next();
            interceptorRegistration.excludePathPatterns(new String[]{url});
        }

        WebMvcConfigurer.super.addInterceptors(registry);
    }
}
